package com.woniuxy.ticket_cinema.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.ticket_cinema.entity.Cinema;
import com.woniuxy.ticket_cinema.entity.ResponseResult;
import com.woniuxy.ticket_cinema.service.CinemaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author booty
 * @since 2021-02-22
 */
@Api(tags = "影院管理接口")
@RestController
@RequestMapping("/cinema")
public class CinemaController {
    @Resource
    private CinemaService cinemaService;

    @ApiOperation("新增影院")
    @GetMapping("/add")
    public ResponseResult add(Cinema cinema){
        cinemaService.add(cinema);
        return new ResponseResult().success();
    }

    @ApiOperation("分页查询所有影院")
    @GetMapping("/findAll")
    public ResponseResult<List<Cinema>> findAll(Page<Cinema> page){
        return new ResponseResult(200,"success",cinemaService.page(page));
    }

    @ApiOperation("根据id查询单个影院信息")
    @GetMapping("/findById")
    public ResponseResult<Cinema> findById(int id){
        return new ResponseResult<Cinema>(200,"success",cinemaService.getById(id));
    }

    @ApiOperation("修改影院")
    @GetMapping("/update")
    public ResponseResult update(Cinema cinema){
        cinemaService.updateCinema(cinema);
        return new ResponseResult(200,"success");
    }
}

